<template>
  <GlobalWindow
      :title="title"
      :visible.sync="visible"
      :confirm-working="isWorking"
      @confirm="confirm"
  >
    <el-form :model="form" ref="form" :rules="rules">
<#list table.operaFields as field>
      <el-form-item label="${field.comment}" prop="${field.camelCaseName}"${field.required?string(' required', '')}>
        <#if field.inputType == 'input'>
        <el-input v-model="form.${field.camelCaseName}" placeholder="请输入${field.comment}" maxlength="${field.inputTypeSettings.maxlength}" v-trim/>
        <#elseif field.inputType == 'textarea'>
        <el-input type="textarea" :rows="${field.inputTypeSettings.rows}" v-model="form.${field.camelCaseName}" placeholder="请输入${field.comment}" maxlength="${field.inputTypeSettings.maxlength}" v-trim/>
        <#elseif field.inputType == 'date'>
        <el-date-picker v-model="form.${field.camelCaseName}" type="date" placeholder="请选择${field.comment}"/>
        <#elseif field.inputType == 'datetime'>
        <el-date-picker v-model="form.${field.camelCaseName}" type="datetime" placeholder="请选择${field.comment}"/>
        <#elseif field.inputType == 'year'>
        <el-date-picker v-model="form.${field.camelCaseName}" type="year" placeholder="请选择${field.comment}"/>
        <#elseif field.inputType == 'month'>
        <el-date-picker v-model="form.${field.camelCaseName}" type="month" placeholder="请选择${field.comment}"/>
        <#elseif field.inputType == 'week'>
        <el-date-picker v-model="form.${field.camelCaseName}" type="week" placeholder="请选择${field.comment}"/>
        </#if>
      </el-form-item>
</#list>
    </el-form>
  </GlobalWindow>
</template>

<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
export default {
  name: 'Opera${table.pascalCaseName}Window',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    return {
      // 表单数据
      form: {
        id: null,
<#list table.operaFields as field>
        ${field.camelCaseName}: ''<#if field_index<table.operaFields?size - 1>,</#if>
</#list>
      },
      // 验证规则
      rules: {
      }
    }
  },
  created () {
    this.config({
      api: '/${moduleName}/${table.kebabCaseName}'
    })
  }
}
</script>
